home *** CD-ROM | disk | FTP | other *** search
- opt o+,ow6-,w+,c+,l+,p=68020,autopc
-
- xref _DOSBase /* DOS lib base */
- xref _myxprunit
- xref _myxprdevice
- xref _xprinit
- xref _protocol
- xref _sendopt
- xref _SendPath
- xref _ReceivePath
- xref _DTBT
- xref _TBT
- xref _TTTM
- xref _TTEFF
- xref _TTCPS
- xref _Online_NFiles
- xref _BatchXfer
- xref _Time_limit
- xref _Time_hrs
- xref _Time_mins
- xref _Time_secs
-
- xdef _xprsequence ;XPR Protocol Send/Recieve
-
- *******************************************************************************
- * XPR-Callback Interface
- * ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
- * Written for the Ami-Express /X3.xx Series,
- * Based around some very old (badly written) example "IntXpr.asm" source.
- *
- * Copyright © 1993-94. All Rights Are Reserved.
- *******************************************************************************
-
- cnop 0,4
- _xprsequence: movem.l d0-d7/a0-a6,-(sp)
-
- call_back: lea cb(pc),a5 ;pc-relativity base
- cb: move.l _DOSBase(a4),DOSBase-cb(a5) ;save base address of dos
- move.l a4,DTBase-cb(a5) ;save offset base
-
- lea relocflag(pc),a0
- tst.w (a0)
- beq.s reloc_done
-
- clr.w (a0)+
- lea 17*4(a0),a1
- moveq #23-1,d0
- reloc: move.l (a0),d1
- beq.s relocskip
- add.l a0,d1
- relocskip: move.l d1,(a0)+
- dbra d0,reloc
-
- moveq #4,d0
- move.l d0,(a1)
- reloc_done:
-
- ;-------------- Open XPR Library (eg; XPRZModem.library') ---------------------
-
- move.l 4.w,a6 ;get execbase
- move.l _protocol(a4),a1 ;name of XPR library to open
- jsr _LVOOldOpenLibrary(a6) ;open any version XPR Library
- move.l d0,XPRBase-cb(a5) ;save base address of XPR
- beq.w XPRFailed ;fail? ELSE we`ve got a base...
-
- ;-------------- Open Serial Device --------------------------------------------
-
- lea SerIO(pc),a1 ;IOExtSer Structure
- moveq #0,d0 ;clear d0
- move.l d0,d1 ;clear d1
- move.b _myxprunit(a4),d0 ;d0=XPR Unit
- move.b #$B4,IO_SERFLAGS(a1) ;set radboogie,7wire,(shared=b4)
- move.l _myxprdevice(a4),a0 ;exclusive = $94
- jsr _LVOOpenDevice(a6) ;open xprdevice
- tst.l d0 ;did it fail?
- bne.w XPRFailed ;if=0 it opened fine,else error
-
- ;-------------- Add Serial ReplyPort ------------------------------------------
-
- suba.l a1,a1 ;no task name... we want this
- jsr _LVOFindTask(a6) ;find 'This task'
- lea SerReply(pc),a1
- move.l d0,MP_SIGTASK(a1)
- jsr _LVOAddPort(a6) ;add a reply (message-)port
- lea SerIO(pc),a1 ;replyport eintragen
- lea SerReply(pc),a0
- move.l a0,MN_REPLYPORT(a1)
-
- ;-------------- Open Timer.Device ---------------------------------------------
-
- lea timer_name(pc),a0 ;ptr to 'timer.device' string
- lea TimeIO(pc),a1 ;ptr to our TimeIO structure
- moveq #UNIT_MICROHZ,d0
- moveq #0,d1
- jsr _LVOOpenDevice(a6) ;open 'timer.device'
- tst.l d0
- bne.s CloseSerial
-
- ;-------------- Add TimerIO Message ReplyPort ---------------------------------
-
- suba.l a1,a1 ;this task
- jsr _LVOFindTask(a6) ;find our task
- lea TimeReply(pc),a1
- move.l d0,MP_SIGTASK(a1) ;save taskadr into sigtask
- jsr _LVOAddPort(a6)
- lea TimeIO(pc),a1 ;replyport
- lea TimeReply(pc),a0
- move.l a0,MN_REPLYPORT(a1)
-
- ;-------------- Call our 'XPR-Transfer Routines' ------------------------------
-
- moveq #0,d0
- move.l d0,_DTBT(a4) ;clear xfer stats
- move.l d0,_TBT(a4)
- move.l d0,_TTTM(a4)
- move.l d0,_TTEFF(a4)
- move.l d0,_TTCPS(a4)
- move.l d0,_Online_NFiles(a4)
-
- move.l d0,TmpCps-cb(a5)
- move.l d0,TmpEff-cb(a5)
- move.l d0,TmpTim-cb(a5)
- move.l d0,TmpSiz-cb(a5)
-
- ;-------------- Begin XPR-Transfer --------------------------------------------
-
- bsr.b XPRTransfer
-
- ;/* [ShutDown] ***************************************************************/
-
- CloseTimer: move.l 4.w,a6 ;get execbase
- lea TimeIO(pc),a1 ;ptr to TimerIO Structure
- jsr _LVOCloseDevice(a6) ;Close Timer Device
- lea TimeReply(pc),a1 ;ptr to TimeReply Structure
- jsr _LVORemPort(a6) ;remove TimerIO ReplyPort
-
- CloseSerial move.l 4.w,a6 ;get execbase
- lea SerIO(pc),a1 ;ptr to SerialIO Structure
- jsr _LVOCloseDevice(a6) ;Close Serial Device
- lea SerReply(pc),a1 ;ptr to Serial ReplyPort
- jsr _LVORemPort(a6) ;remove Serial ReplyPort
-
- CloseXPRLib lea cb(pc),a5
- move.l 4.w,a6 ;get execbase
- move.l XPRBase(pc),d0 ;base of library to close
- beq.s XPRFailed
- clr.l XPRBase-cb(a5)
- move.l d0,a1
- jsr _LVOCloseLibrary(a6) ;close the library
-
- XPRFailed movem.l (sp)+,d0-d7/a0-a6
- rts
-
-
- ;/* [Transfer] ***************************************************************/
-
- cnop 0,4
- XPRTransfer: tst.b _sendopt(a4)
- bne.s Send
-
- Receive: lea XPR_IO(pc),a0
- move.l _xprinit(a4),(a0)
- move.l XPRBase(pc),a6
- jsr -36(a6) ;_LVOSetup (general params)
-
- move.l a4,-(sp)
- move.l DTBase(pc),a4
- move.l _ReceivePath(a4),a2
- move.l (sp)+,a4
-
- move.b #"P",(a2)
- lea XPR_IO(pc),a0
- move.l a2,(a0)
- jsr -36(a6) ;_LVOSetup (receive path)
- lea XPR_IO(pc),a0
- jsr -48(a6) ;_LVOReceive
- lea XPR_IO(pc),a0
- jmp -30(a6) ;_LVOCleanup
-
- Send lea XPR_IO(pc),a0
- move.l _xprinit(a4),(a0)
- move.l XPRBase(pc),a6
- jsr -36(a6) ;Setup general params
-
- move.l a4,-(sp)
- move.l DTBase(pc),a4
- move.l _SendPath(a4),a1
- move.l (sp)+,a4
-
- lea XPR_IO(pc),a0
- move.l a1,(a0) ;give pointer to ffirst/fnext
- jsr -42(a6) ;Send
- lea XPR_IO(pc),a0
- jmp -30(a6) ;Cleanup
-
- cnop 0,4
- AddTmps: move.l a4,-(sp)
- move.l d0,-(sp)
- move.l DTBase(pc),a4
- move.l TmpCps(pc),d0
- add.l d0,_TTCPS(a4)
- move.l TmpEff(pc),d0
- add.l d0,_TTEFF(a4)
- move.l TmpTim(pc),d0
- add.l d0,_TTTM(a4)
-
- move.b _sendopt(a4),d0
- beq.s noRecSize
- move.l TmpSiz(pc),d0
- add.l d0,_TBT(a4)
- moveq #1,d0
- add.l d0,_Online_NFiles(a4)
- noRecSize move.l (sp)+,d0
- move.l (sp)+,a4
-
- ResetTmps: move.l a5,-(sp)
- lea cb(pc),a5
- clr.l TmpCps-cb(a5)
- clr.l TmpEff-cb(a5)
- clr.l TmpTim-cb(a5)
- clr.l TmpSiz-cb(a5)
- move.l (sp)+,a5
- rts
-
- ;/* [xpr_fopen] *************************************************************/
- ;/* */
- ;/* $Outputs: a0.l = char *filename */
- ;/* a1.l = char *accessmode */
- ;/* */
- cnop 0,4
- xpr_fopen: move.l DOSBase(pc),a6
- move.l a0,d1
- move.b (a1),d0
- bclr #5,d0 ;cap. letters
- cmpi.b #"R",d0
- bne.b noMODE_READ
- move.l #MODE_OLDFILE,d2
- jmp _LVOOpen(a6) ;d1^name d2=mode
-
- cnop 0,4
- noMODE_READ cmpi.b #"W",d0
- bne.b noMODE_WRITE
- move.l #MODE_NEWFILE,d2
- jmp _LVOOpen(a6) ;d1^name d2=mode
-
- cnop 0,4
- noMODE_WRITE cmpi.b #"A",d0
- bne.b noMODE_APPEND
- move.l d1,d5 ;save ^name
- move.l #MODE_OLDFILE,d2
- jsr _LVOOpen(a6)
- tst.l d0
- bne.b OPENok
- move.l d5,d1
- move.l #MODE_NEWFILE,d2
- jmp _LVOOpen(a6)
-
- cnop 0,4
- OPENok move.l d0,d5 ;save handle
- move.l d0,d1 ;goto end of file (append)
- moveq #0,d2
- moveq #OFFSET_END,d3
- jsr _LVOSeek(a6)
- move.l d5,d0 ;handle in d0 must be returned
- rts
-
- cnop 0,4
- noMODE_APPEND moveq #0,d0
- rts ;do nothing
-
-
- ;/* [xpr_fclose] ************************************************************/
- ;/* */
- ;/* $Outputs: a0.l = char *filepointer */
- ;/* */
-
- cnop 0,4
- xpr_fclose move.l a0,d1
- move.l DOSBase(pc),a6
- jsr _LVOClose(a6)
- bra.w AddTmps
-
- ;/* [xpr_fread] *************************************************************/
- ;/* */
- ;/* $Outputs: a0 = char *buffer */
- ;/* d0 = long *size */
- ;/* d1 = long *count */
- ;/* a1 = long fileptr */
- ;/* */
-
- cnop 0,4
- xpr_fread move.l d1,d3 ;length
- move.l a0,d2 ;buffer
- move.l a1,d1 ;file-handle
- move.l DOSBase(pc),a6
- jmp _LVORead(a6)
-
- ;/* [xpr_fwrite] ************************************************************/
- ;/* */
- ;/* $Outputs: a0 = char *buffer */
- ;/* d0 = long *size */
- ;/* d1 = long count */
- ;/* a1 = long fileptr */
- cnop 0,4
-
- xpr_fwrite move.l d1,d3 ;length
- move.l a0,d2 ;buffer
- move.l a1,d1 ;file-handle
- move.l DOSBase(pc),a6
- jmp _LVOWrite(a6)
-
- ;/* [xpr_squery] ************************************************************/
- ;/* */
- ;/* $Outputs: None (void) */
-
- cnop 0,4
- xpr_squery lea SerIO(pc),a1
- move.w #SDCMD_QUERY,IO_COMMAND(a1)
- move.l 4.w,a6
- jsr _LVODoIO(a6)
- lea SerIO(pc),a1
- move.l IO_ACTUAL(a1),d0
- rts
-
- ;/* [xpr_sread] *************************************************************/
- ;/* */
- ;/* $Outputs: a0 = char *buffer */
- ;/* d0 = long size */
- ;/* d1 = long timeout */
-
- cnop 0,4
- xpr_sread lea cb(pc),a1
- move.l a0,IO_DataPt-cb(a1) ;IO_DATA
- move.l d0,IO_Size-cb(a1) ;IO_LENGTH
- move.l d1,IO_TimeOut-cb(a1) ;timeout or 0
- bne.s wantsTIMEOUT
-
- bsr.s xpr_squery
- tst.l d0
- beq.s read_done
-
- lea SerIO(pc),a1
- move.w #CMD_READ,IO_COMMAND(a1)
- move.l IO_DataPt(pc),IO_DATA(a1)
- move.l IO_Size(pc),IO_LENGTH(a1)
- cmp.l IO_Size(pc),d0
- bcc.s read_ok ;more than asked for?
- move.l d0,IO_LENGTH(a1)
- read_ok: move.l 4.w,a6
- jsr _LVODoIO(a6)
- move.l IO_ACTUAL(a1),d0
- read_done: rts ;return with count=0
-
- cnop 0,4
- wantsTIMEOUT: lea SerIO(pc),a1
- move.w #CMD_READ,IO_COMMAND(a1)
- move.l IO_Size(pc),IO_LENGTH(a1)
- move.l IO_DataPt(pc),IO_DATA(a1)
- move.l 4.w,a6
- jsr _LVOSendIO(a6) ;DoIO would not return
-
- lea TimeIO(pc),a1
- move.w #TR_ADDREQUEST,IO_COMMAND(a1)
- move.l IO_TimeOut(pc),$24(a1) ;timeout in microsecs
- clr.l $20(a1) ;0 secs
- jsr _LVOSendIO(a6)
-
- noTIMER lea SerReply(pc),a1 ;generate waitmaske
- moveq #0,d0 ;wait: either asked # of bytes arrive or
- move.l d0,d1 ;timerequest returns (timeout)
- move.b MP_SIGBIT(a1),d1
- bset.l d1,d0
- lea TimeReply(pc),a1
- move.b MP_SIGBIT(a1),d1
- bset d1,d0
- move.l 4.w,a6
- jsr _LVOWait(a6) ;timeout!enough_bytes
-
- lea SerIO(pc),a1 ;ok, iam back who signaled me?
- jsr _LVOCheckIO(a6) ;was it the SerReqptr?
- beq.s noSERIAL
- jsr _LVOWaitIO(a6) ;SERIAL did it: cleanup serial
-
- lea TimeIO(pc),a1 ;abort timer
- jsr _LVOAbortIO(a6)
- lea TimeIO(pc),a1
- jsr _LVOWaitIO(a6) ;cleanup timer
-
- lea SerIO(pc),a1
- move.l IO_ACTUAL(a1),d0 ;probably the IO_ACTUAL = # of asked bytes
- rts
-
- cnop 0,4
- noSERIAL lea TimeIO(pc),a1 ;timeout?
- move.l 4.w,a6
- jsr _LVOCheckIO(a6)
- beq.s noTIMER ;something else did it...return to sleep
- jsr _LVOWaitIO(a6)
-
- lea SerIO(pc),a1 ;abort serial
- jsr _LVOAbortIO(a6)
- lea SerIO(pc),a1
- jsr _LVOWaitIO(a6)
-
- lea SerIO(pc),a1
- move.l IO_ACTUAL(a1),d0 ;probably IO_ACTUAL=0
- rts
-
- ;/* [xpr_swrite] ************************************************************/
- ;/* */
- ;/* $Outputs: a0 = char *buffer */
- ;/* d0 = long size */
-
- cnop 0,4
- xpr_swrite: lea SerIO(pc),a1
- move.w #CMD_WRITE,IO_COMMAND(a1)
- move.l d0,IO_LENGTH(a1)
- move.l a0,IO_DATA(a1)
- move.l 4.w,a6
- jmp _LVODoIO(a6)
-
- ;/* [xpr_sflush] ************************************************************/
- ;/* */
- ;/* $Outputs: None (void) */
-
- cnop 0,4
- xpr_sflush: lea SerIO(pc),a1
- move.w #CMD_FLUSH,IO_COMMAND(a1)
- move.l 4.w,a6
- jmp _LVODoIO(a6)
-
-
- ;/* [xpr_update] ************************************************************/
- ;/* */
- ;/* $Outputs: a0 = struct XPR_UPDATE *updatestruct */
-
- cnop 0,4
- xpr_update move.l a5,-(sp)
- lea cb(pc),a5
-
- move.l a0,a1
- move.l (a0),d5 ;update mask (what fields have changed)
- btst #1,d5
- beq.s noFileName
- move.l 8(a1),a0 ;filename
-
- noFileName btst #2,d5
- beq.s noFileSize
- move.l 12(a1),TmpSiz-cb(a5) ;file length
-
- noFileSize btst #3,d5
- beq.s noMSG
- move.l 16(a1),d0 ;status msg
-
- noMSG btst #4,d5
- beq.s noCPS
- move.l 20(a1),d0 ;error msg
-
- noCPS btst #7,d5
- beq.s noBYTES
- move.l 32(a1),d0 ;byte position
-
- noBYTES btst #14,d5
- beq.s noEXPECT
- move.l 60(a1),d0 ;expect time
-
- noEXPECT btst #15,d5
- beq.s noELAPSED
- move.l 64(a1),d0 ;elapsed time
-
- noELAPSED btst #16,d5
- beq.s noUPDATE
- move.l 68(a1),TmpCps-cb(a5) ;cps rate
-
- noUPDATE move.w #$00f,$dff180
-
- move.l (sp)+,a5
- rts
-
-
- ;/* [xpr_chkabort] **********************************************************/
- ;/* */
- ;/* $Outputs: None (void) */
-
- cnop 0,4
- xpr_chkabort: bsr.w xpr_squery ;vielleicht zu lang fuer isdn?
- move.w IO_STATUS(a1),d0
- btst #5,d0 ;CARRIER LOST?
- bne.s yoABORT
- noABORT moveq #0,d0 ;proceed with transmittion
- rts
- yoABORT moveq #-1,d0 ;abort transmittion
- rts
-
-
- ;/* [xpr_chkmisc] ***********************************************************/
- ;/* */
- ;/* $Outputs: None (void) */
-
- cnop 0,4
- xpr_chkmisc ;/* NOT IMPLEMENTED! */
- rts
-
-
- ;/* [xpr_gets] **************************************************************/
- ;/* */
- ;/* $Outputs: a0 = char *prompt */
- ;/* a1 = char *buffer */
-
- cnop 0,4
- xpr_gets ;/* NOT IMPLEMENTED! */
- rts
-
- ;/* [xpr_setserial] *********************************************************/
- ;/* */
- ;/* $Outputs: d0 = long newstatus */
-
- cnop 0,4
- xpr_setserial ;/* NOT IMPLEMENTED! */
- rts
-
-
- ;/* [xpr_ffirst] ************************************************************/
- ;/* */
- ;/* $Outputs: a0 = char *buffer */
- ;/* a1 = char *pattern */
-
- cnop 0,4
- xpr_ffirst move.b #" ",d0
- tst.b (a1) ;"amixpr s ",0
- beq.b ffirst_null
- cmp.b (a1),d0 ;"amixpr s ",0
- beq.b ffirst_null
- ffirst_loop move.b (a1)+,(a0)+
- beq.b ffirst_end
- cmp.b (a1),d0
- bne.b ffirst_loop
- ffirst_end sf.b (a0) ;terminate name with zero
- move.l a1,d0 ;wird fnext uebergeben in d0
- rts
- cnop 0,4
- ffirst_null moveq #0,d0 ;no file found
- rts
-
- ;/* [xpr_fnext] *************************************************************/
- ;/* */
- ;/* $Outputs: d0 = long oldstate */
- ;/* a0 = char *buffer */
- ;/* a1 = char *pattern */
-
- cnop 0,4
- xpr_fnext move.l d0,a1
- move.b #" ",d0
- tst.b (a1)+ ; ^
- beq.b fnext_null ;"oldname",0
- tst.b (a1)
- beq.b fnext_null ;"oldname ",0
- cmp.b (a1),d0
- beq.b fnext_null ;"oldname "
- fnext_loop move.b (a1)+,(a0)+
- beq.b fnext_end
- cmp.b (a1),d0 ;liest solange bis er ein space findet
- bne.b fnext_loop
- fnext_end sf.b (a0)
- move.l a1,d0
- rts
- cnop 0,4
- fnext_null moveq #0,d0 ;no file found
- rts
-
- ;/* [xpr_finfo] *************************************************************/
- ;/* */
- ;/* $Outputs: a0 = char *filename */
- ;/* d0 = long typeofinfo */
-
- cnop 0,4
- xpr_finfo: move.l d0,-(sp)
- move.l a0,d1
- moveq #-2,d2
- move.l DOSBase(pc),a6
- jsr _LVOLock(a6)
- move.l d0,d1
- beq.s finfo
-
- move.l d0,-(sp)
- move.l d0,d1
- lea FIB(pc),a0
- move.l a0,d2
- jsr _LVOExamine(a6)
- move.l (sp)+,d1
- jsr _LVOUnLock(a6)
-
- move.l (sp)+,d0
- moveq #2,d1
- cmp.l d1,d0
- beq.b finfo
- subq.l #1,d1
- cmp.l d1,d0
- bne.b finfo
- lea FIB(pc),a0
- move.l 124(a0),d0 ;anzahl bytes
- rts
- cnop 0,4
- finfo moveq #0,d0
- rts
-
- ;/* [xpr_fseek] *************************************************************/
- ;/* */
- ;/* $Outputs: a0 = long fileptr */
- ;/* d0 = long offset */
- ;/* d1 = long origin */
-
- cnop 0,4
- xpr_fseek: move.l d1,d3 ;Modus offset_beginning/current/end
- move.l d0,d2 ;Abstand
- move.l a0,d1 ;Handle
- subq.l #1,d3
- move.l DOSBase(pc),a6
- jsr _LVOSeek(a6)
- tst.l d0
- bmi.s fseek1
- moveq #0,d0 ;0=success
- fseek1 rts
-
-
- ;/* [xpr_options] ***********************************************************/
- ;/* */
- ;/* $Outputs: d0 = long n */
- ;/* a0 = struct xpr_option **opt */
-
- cnop 0,4
- xpr_options ;/* NOT IMPLEMENTED! */
- rts
-
- ;/* [xpr_unlink] ************************************************************/
- ;/* */
- ;/* $Outputs: a0 = char *filename */
-
- cnop 0,4
- xpr_unlink: move.l a0,d1
- move.l DOSBase(pc),a6
- jsr _LVODeleteFile(a6)
- tst.l d0
- beq.s unlink
- moveq #-1,d0
- rts
- cnop 0,4
- unlink moveq #0,d0
- rts
-
- ;/* [xpr_getptr] ************************************************************/
- ;/* */
- ;/* $Outputs: d0 = long type */
-
- cnop 0,4
- xpr_getptr ;/* NOT IMPLEMENTED! */
- rts
-
- cnop 0,4
- relocflag dc.w -1
- XPR_IO dc.l 0
- dc.l xpr_fopen-* ;a pointer to this struct must be given
- dc.l xpr_fclose-* ;whenever calling a xprlib function
- dc.l xpr_fread-*
- dc.l xpr_fwrite-*
- dc.l xpr_sread-*
- dc.l xpr_swrite-*
- dc.l xpr_sflush-*
- dc.l xpr_update-*
- dc.l xpr_chkabort-*
- dc.l 0 ;not implemented
- dc.l 0 ;not implemented
- dc.l 0 ;not implemented
- dc.l xpr_ffirst-*
- dc.l xpr_fnext-*
- dc.l xpr_finfo-*
- dc.l xpr_fseek-*
- dc.l 0 ;4;alle 4 EXT fields programmiert
- dc.l 0
- dc.l xpr_options-* ;EXT1 - not implemented
- dc.l xpr_unlink-* ;EXT2
- dc.l xpr_squery-* ;EXT3
- dc.l xpr_getptr-* ;EXT4 - not implemented
- dc.l 0,0,0,0
- cnop 0,4
- DTBase ds.l 1
- DOSBase ds.l 1
- XPRBase ds.l 1
- TmpCps ds.l 1
- TmpEff ds.l 1
- TmpTim ds.l 1
- TmpSiz ds.l 1
- IO_DataPt ds.l 1
- IO_Size ds.l 1
- IO_TimeOut ds.l 1
- SerIO ds.b 96 ;IOExtSer Alloc for Message and Replyports
- SerReply ds.b 48
- TimeIO ds.b 48
- TimeReply ds.b 48
- cnop 0,4 ;*MUST* be longword aligned!
- FIB ds.b 260 ;file-info-block alloc
- even
- timer_name dc.b 'timer.device',0
-